{% extends "cfp/event/base.html" %}

{% load compress %}
{% load datetimerange %}
{% load event_tags %}
{% load html_signal %}
{% load i18n %}
{% load rich_text %}
{% load rules %}
{% load static %}

{% block title %}{% translate "Your proposals" %} :: {% endblock title %}

{% block scripts %}
    {% compress js %}
        <script defer src="{% static "common/js/copy.js" %}"></script>
        <script defer src="{% static "vendored/moment-with-locales.js" %}"></script>
        <script defer src="{% static "vendored/moment-timezone-with-data-10-year-range.js" %}"></script>
        <script defer src="{% static "agenda/js/datetime-local.js" %}"></script>
    {% endcompress %}
{% endblock scripts %}

{% block content %}
    {% if information %}
        <h2>{% translate "Important Information" %}</h2>
        {% for info in information %}
            <h4>{{ info.title }}</h4>
            {{ info.text|rich_text }}
            {% if info.resource %}
                <a href="{{ info.resource.url }}"><i class="fa fa-file-o"></i> {{ info.resource.name }}</a>
            {% endif %}
            {% if not forloop.last %}<hr>{% endif %}
        {% endfor %}
    {% endif %}
    {% html_signal "eventyay.cfp.signals.html_above_submission_list" sender=request.event request=request %}
    {% if drafts %}
        <h2>{% translate "Your drafts" %}</h2>
        <div class="table-responsive">
            <table class="table table-sm table-flip">
                <thead>
                    <tr>
                        <th>{% translate "Title" %}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for submission in drafts %}
                        <tr>
                            <td>
                                <a href="{{ submission.urls.user_base }}">{{ submission.title }}</a>
                            </td>
                            <td class="flip text-right">
                                {% if submission.review_code and request.event|get_feature_flag:"submission_public_review" %}
                                    <button data-destination="{{ submission.urls.review.full }}"
                                            class="btn btn-sm btn-info copyable-text"
                                            data-toggle="tooltip"
                                            data-placement="left"
                                            title="{% translate "Copy code for review" %}"
                                            target="_blank"
                                            rel="noopener">
                                        <i class="fa fa-link"></i>
                                    </button>
                                {% endif %}
                                <a href="{{ submission.urls.user_base }}" class="btn btn-sm btn-success">
                                    {% if submission.editable %}
                                        <i class="fa fa-edit" title="{% translate "Edit draft" %}"></i>
                                    {% else %}
                                        <i class="fa fa-edit" title="{% translate "Open draft" %}"></i>
                                    {% endif %}
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    {% endif %}
    <h2>{% translate "Your proposals" %}</h2>
    {% if submissions %}
        <div class="table-responsive">
            <table class="table table-sm table-flip">
                <thead>
                    <tr>
                        <th>{% translate "Title" %}</th>
                        <th>{% translate "State" %}</th>
                        <th></th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for submission in submissions %}
                        <tr>
                            <td>
                                <a href="{{ submission.urls.user_base }}">{{ submission.title }}</a>
                            </td>
                            <td>

                                {% include "cfp/event/fragment_state.html" with state=submission.user_state as_badge=True %}

                            </td>
                            <td class="flip text-right">
                                {% if submission.public_slots %}
                                    <a href="{{ submission.urls.public }}">
                                        {% for talk in submission.public_slots %}
                                            {{ talk.start|datetimerange:talk.end }}, {{ talk.room.name }}
                                            {% if not forloop.last %}<br>{% endif %}
                                        {% endfor %}
                                    </a>
                                {% endif %}
                            </td>
                            <td class="flip text-right">
                                {% if submission.review_code and request.event|get_feature_flag:"submission_public_review" %}
                                    <button data-destination="{{ submission.urls.review.full }}"
                                            class="btn btn-sm btn-info copyable-text"
                                            data-toggle="tooltip"
                                            data-placement="left"
                                            title="{% translate "Copy code for review" %}"
                                            target="_blank"
                                            rel="noopener">
                                        <i class="fa fa-link"></i>
                                    </button>
                                {% endif %}
                                <a href="{{ submission.urls.user_base }}" class="btn btn-sm btn-info">
                                    {% if submission.editable %}
                                        <i class="fa fa-edit" title="{% translate "Edit proposal" %}"></i>
                                    {% else %}
                                        <i class="fa fa-edit" title="{% translate "Open proposal" %}"></i>
                                    {% endif %}
                                </a>
                                {% if submission.state == "accepted" %}
                                    <a href="{{ submission.urls.confirm }}" class="btn btn-sm btn-success">
                                        <i class="fa fa-check"></i> {% translate "Confirm" %}
                                    </a>
                                {% endif %}
                                {% if request.event|get_feature_flag:"use_feedback" and submission.does_accept_feedback %}
                                    <a href="{{ submission.urls.feedback }}" class="btn btn-sm btn-info">
                                        <i class="fa fa-comments"></i> {% translate "Feedback" %}
                                        {% if submission.feedback.count %}({{ submission.feedback.count }}){% endif %}
                                    </a>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <p>
            {% if request.event.cfp.is_open %}
                <a class="btn btn-success btn-lg" href="{{ request.event.urls.submit }}">{% translate "Create a new proposal" %}</a>
            {% endif %}
        </p>
    {% else %}
        <p class="text-center">{% translate "It seems like you haven’t submitted anything to this event yet." %}</p>
        <p class="text-center">{% translate "If you did, maybe you used a different account? Check your emails!" %}</p>
        {% if request.event.cfp.is_open %}
            <p class="text-center">
                {% translate "If you did not, why not go ahead and create a proposal now? We’d love to hear from you!" %}
            </p>
            <p class="text-center">
                <a class="btn btn-success btn-lg btn-block"
                   href="{{ request.event.urls.submit }}">
                    {% translate "Submit something now!" %}
                </a>
            </p>
        {% endif %}
    {% endif %}
{% endblock content %}
